﻿namespace Game500.Server

open Microsoft.Xna.Framework
open System.Xml.Serialization

type PlaneParameters(s : string) =
    let mutable mass = 3400.0f
    let mutable lift = 0.1f
    let mutable air = 100.f
    let mutable air2 = 1.f
    let mutable rad = 5.0f
    let mutable typeID = s
    let mutable shape = [| new Vector2(-45.0f, 0.0f); new Vector2(45.0f, 15.0f); new Vector2(45.0f, -15.0f) |]

    new() = PlaneParameters("")
    member o.Mass
        with get () = mass
        and set m = mass <- m
    member o.Lift
        with get () = lift
        and set l = lift <- l
    member o.Air
        with get () = air
        and set a = air <- a
    member o.Air2
        with get () = air2
        and set a = air2 <- a
    member o.Radius
        with get () = rad
        and set r = rad <- r
    member o.Shape
        with get () = shape
        and set s = shape <- s
    [<XmlAttribute("type")>]
    member o.TypeID
        with get () = typeID
        and  set id = typeID <- id
    
type Parameters() =
    let mutable gravity = 50.0f
    let mutable bullet_distance = 500.0f
    let mutable bullet_speed = 500.0f
    let mutable tangage_coef = 0.00005f
    let mutable throttle_coef = 800000.0f
    let mutable bullet_freq = 0.1f
    let mutable max_speed = 800.0f
    let mutable bullet_radius = 0.1f
    let mutable planes = [| new PlaneParameters("biplane") |] 
    let mutable distortion = 0.13f
    let mutable landing_speed_threshold = 300.0f
    let mutable landing_rotation_threshold = 0.4f
    let mutable respawn_timeout = 3.0

    member o.Gravity
        with get() = gravity
        and set(g) = gravity <- g
    member o.BulletDistance
        with get() = bullet_distance
        and set(d) = bullet_distance <- d
    member o.BulletSpeed
        with get() = bullet_speed
        and set(s) = bullet_speed <- s
    member o.BulletRadius
        with get() = bullet_radius
        and set(r) = bullet_radius <- r
    member o.TangageCoef
        with get() = tangage_coef
        and set(c) = tangage_coef <- c
    member o.ThrottleCoef
        with get() = throttle_coef
        and set(c) = throttle_coef <- c
    member o.BulletFreq
        with get() = bullet_freq
        and set(f) = bullet_freq <- f
    member o.MaxSpeed
        with get() = max_speed
        and set(m) = max_speed <- m
    member o.Planes
        with get() = planes
        and set(p) = planes <- p
    member o.Distortion
        with get() = distortion
        and set d = distortion <- d
    member o.LandingSpeedThreshold
        with get() = landing_speed_threshold
        and set l = landing_speed_threshold <- l
    member o.LandingRotationThreshold
        with get() = landing_rotation_threshold
        and set l = landing_rotation_threshold <- l
    member o.RespawnTimeout
        with get() = respawn_timeout
        and set r = respawn_timeout <- r
